ARG PHP_VERSION
FROM ${PHP_VERSION}

# Init
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && apk update \
    && apk add --no-cache autoconf g++ libtool make curl-dev gettext-dev libpng-dev freetype-dev libjpeg-turbo-dev \
	&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/  \
    && docker-php-ext-install -j$(nproc) mysqli pdo_mysql gd

# Extensions
ARG PHPREDIS_VERSION=4.1.0
COPY ./extensions /tmp/extensions
WORKDIR /tmp/extensions
RUN pecl install redis-${PHPREDIS_VERSION}.tgz \
    && docker-php-ext-enable redis \
    && rm -rf /tmp/extensions

WORKDIR /www